/**
 * 一些业务逻辑的基础和共用代码
 */
const vscode = require('vscode');
const path = require('path');
const { confirmDir, nomalizePath, info } = require('./utils.js')

//取出来为/d:/testWorkspace/vue/noCli,注意前面有一个/,在windows系统上需要去掉
let workSpacePath;
try{
    workSpacePath = vscode.workspace.workspaceFolders[0].uri.path;
}catch(e){
    vscode.window.showErrorMessage('请在工作空间目录中使用mxdev!');
    throw e;
}

//windows系统要去掉前面的/
workSpacePath = nomalizePath(workSpacePath);

/**
 * mxDev内部文件的根目录绝对路径
 */
const basePath = path.join(workSpacePath, './.mxDev/');
/**
 * 保存点的文件目录,保存点保存着历史上各个时间点设计文件的配置
 */
const savePointDir = path.join(basePath, './savePoint/');

const frameworkDir = path.join(basePath, './frameworks/');
//异步的创建一下这个目录,防止报错
setTimeout(_ => {
    confirmDir(path.join(frameworkDir, 'v2'));
}, 0);


let extensionPath;
function setExtensionPath(_extensionPath) {
    extensionPath = _extensionPath;
}

function getExtensionPath() {
    return extensionPath;
}


module.exports = { workSpacePath, basePath, savePointDir, frameworkDir, setExtensionPath, getExtensionPath }